#include "stdafx.h"
#include "Account.h"
#include "Character.h"

CAccount::CAccount()
	: m_online(false), m_channelId(-1), m_state(STATE_AUTH)
{
	m_characters[0] = null;
	m_characters[1] = null;
	m_characters[2] = null;
}

CAccount::~CAccount()
{
	solve();
}

const char* CAccount::getPassword() const
{
	return m_password.c_str();
}

E_ACCESS_LEVEL CAccount::getAccessLevel() const
{
	return m_access;
}

bool CAccount::isOnline() const
{
	return m_online;
}

void CAccount::setOnline(bool online)
{
	m_online = online;
}

void CAccount::setState(E_STATE state)
{
	m_state = state;
}

int CAccount::getId() const
{
	return m_id;
}

const char* CAccount::getUsername() const
{
	return m_username.c_str();
}

E_STATE CAccount::getState() const
{
	return m_state;
}

bool CAccount::isBanned() const
{
	return (m_access == ACC_BANNED
		|| m_bantime >= CTime::seconds());
}

void CAccount::setChannel(int id)
{
	m_channelId = id;
}

int CAccount::getChannel()
{
	return m_channelId;
}

void CAccount::solve()
{
	for(int i = 0; i < 3; i++)
	{
		if(m_characters[i])
		{
			delete m_characters[i];
			m_characters[i] = null;
		}
	}
}

CCharacter* CAccount::getCharacter(int place)
{
	return m_characters[place];
}